package cn.school.hotel.service.impl;

import cn.school.hotel.dao.TripHotelCommentDao;
import cn.school.hotel.entity.TripComment;
import cn.school.hotel.service.TripCommentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("tripCommentService")
public class TripCommentServiceImpl implements TripCommentService {

    @Autowired
    private TripHotelCommentDao tripHotelCommentDao;

    @Override
    public IPage<TripComment> getHotelCommentPagelist(TripComment tripComment, Integer pageSize, Integer pageNum) {
        int count =  tripHotelCommentDao.getCommentListCount(tripComment);
        int startNum=(pageNum-1)*pageSize;
        List<TripComment> commentList =  tripHotelCommentDao.getCommentList(tripComment, startNum, pageSize);
        IPage<TripComment> page = new Page<>();
        page.setTotal(count);
        page.setRecords(commentList);
        return page;
    }
}
